//
// example 13.2tx - http://tronixstuff.com/tutorials > Chapter 13
// 
// basic tx sketch - based on code by Mike McCauley 2010 http://www.open.com.au/mikem/arduino
//
// don't forget the 10k resistor between digital pin 0 and GND for independent operation

// Need these lines below ///////////////////
#include <VirtualWire.h> 
#undef int
#undef abs
#undef double
#undef float
#undef round
////////////////////////////////////////////

void setup()
{
  // Initialise the IO and ISR
  vw_set_ptt_inverted(true);      // Required for RF Link module
  vw_setup(2400);                 // Bits per sec
  vw_set_tx_pin(1);               // pin 1 is the TX pin on our Arduino Duemilanove
  pinMode(8, INPUT);      // for each of the four buttons 
  pinMode(9, INPUT);
  pinMode(10, INPUT);
  pinMode(11, INPUT);
  delay(2000); // give the radio module time to get going
}

const char *l1 = "a"; // a~h will represent the states of the four buttons, 1~4 high or low
const char *h1 = "b"; // the less data to send wirelessly the better
const char *l2 = "c"; 
const char *h2 = "d";      
const char *l3 = "e";      
const char *h3 = "f";      
const char *l4 = "g";
const char *h4 = "h";

void loop()
{
  if (digitalRead(8)==LOW)
  {
    vw_send((uint8_t *)l1, strlen(l1));   // send the data out to the world
    vw_wait_tx();     // Wait for sending of message to finish.  
    delay(20);
  } 
  else if (digitalRead(8)==HIGH)
  {
    vw_send((uint8_t *)h1, strlen(h1));   // send the data out to the world
    vw_wait_tx();                           // Wait for sending of message to finish.  
  }
  delay(20);
  if (digitalRead(9)==LOW)
  {
    vw_send((uint8_t *)l2, strlen(l2));   // send the data out to the world
    vw_wait_tx();                           // Wait for sending of message to finish.  
    delay(20);
  } 
  else if (digitalRead(9)==HIGH)
  {
    vw_send((uint8_t *)h2, strlen(h2));   // send the data out to the world
    vw_wait_tx();                           // Wait for sending of message to finish.  
  }
  delay(20);
  if (digitalRead(10)==LOW)
  {
    vw_send((uint8_t *)l3, strlen(l3));   // send the data out to the world
    vw_wait_tx();                           // Wait for sending of message to finish.  
    delay(20);
  } 
  else if (digitalRead(10)==HIGH)
  {
    vw_send((uint8_t *)h3, strlen(h3));   // send the data out to the world
    vw_wait_tx();                           // Wait for sending of message to finish.  
  }
  delay(20);
  if (digitalRead(11)==LOW)
  {
    vw_send((uint8_t *)l4, strlen(l4));   // send the data out to the world
    vw_wait_tx();                           // Wait for sending of message to finish. 
    delay(20); 
  } 
  else if (digitalRead(11)==HIGH)
  {
    vw_send((uint8_t *)h4, strlen(h4));   // send the data out to the world
    vw_wait_tx();                           // Wait for sending of message to finish.  
    delay(20);
  }
}

